package com.juzipi.demo.service;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.juzipi.demo.mapper.UserRoleMapper;
import com.juzipi.demo.pojo.UserRole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserRoleService {


    @Autowired
    private UserRoleMapper userRoleMapper;


    public List<UserRole> queryUserRoleList(Long id){
//        QueryWrapper<UserRole> wrapper = new QueryWrapper<>();
//        //又忘了，这种字段要跟数据库的写法一样
//        wrapper.eq("user_id",id);

        return userRoleMapper.selectList(new QueryWrapper<UserRole>().lambda().eq(UserRole::getUserId,id));


    }

    public void createUserRole(UserRole userRole) {
        userRoleMapper.insert(userRole);
    }
}
